﻿/// /////////////////////////////////////////////
// 单元名 : unitSvrMngCommon
// 作者 : Hawk
// 单元描述 : 服务对象服务器管理消息定义
// 日期 : 2023-09-15
/// /////////////////////////////////////////////

{$IFDEF FPC}
{$H+}
{$MODE DELPHI}
{$ENDIF}
unit unitSvrMngCommon;

interface

uses
{$IFDEF MSWINDOWS}
  Windows,
{$ENDIF}
  unitCommonTypes, unitCommonDataStruct, unitIOCPDataObj, unitMsgObj, unitClassIDDef, unitLogCommon, unitObjBase, unitCommonClasses;

const
  SVRMNG_MINORFUNC_GENERAL = 0;
  SVRMNG_MINORFUNC_CLIENTUPDATE = 1;
  SVRMNG_MINORFUNC_FILESYSTEM = 2;
  SVRMNG_MINORFUNC_REMOTEDESKTOP = 4;
  SVRMNG_MINORFUNC_DEBUG = 8;
  SVRMNG_MINORFUNC_SOFTAUTH = 16;

  MESID_SVRMNG_START = CLASSID_SVRMNGPROCOBJ shl MESID_MAJORFUNC_SHIFT;
  MESID_SVRMNG_GETPROCESSINFO = MESID_SVRMNG_START + SVRMNG_MINORFUNC_GENERAL shl MESID_MINORFUNC_SHIFT +
    MESID_OPERATOR_INTERNAL + MESID_OPERATOR_AUDIT + 4;
  MESID_SVRMNG_BROADCASTSVRINFO = MESID_SVRMNG_START + SVRMNG_MINORFUNC_GENERAL shl MESID_MINORFUNC_SHIFT +
    MESID_OPERATOR_AUDIT + 5;
  MESID_SVRMNG_FREEOBJPOOL = MESID_SVRMNG_START + SVRMNG_MINORFUNC_DEBUG shl MESID_MINORFUNC_SHIFT +
    MESID_OPERATOR_ACCESS + MESID_OPERATOR_AUDIT + 7;
  MESID_SVRMNG_GET_OBJPOOLINFO = MESID_SVRMNG_START + SVRMNG_MINORFUNC_DEBUG shl MESID_MINORFUNC_SHIFT +
    MESID_OPERATOR_ACCESS + MESID_OPERATOR_AUDIT + 8;
  MESID_SVRMNG_GET_SVRPROCOBJ = MESID_SVRMNG_START + SVRMNG_MINORFUNC_DEBUG shl MESID_MINORFUNC_SHIFT +
    MESID_OPERATOR_ACCESS + MESID_OPERATOR_AUDIT + 10;
  MESID_SVRMNG_SET_OBJPOOLINFO = MESID_SVRMNG_START + SVRMNG_MINORFUNC_DEBUG shl MESID_MINORFUNC_SHIFT +
    MESID_OPERATOR_ACCESS + MESID_OPERATOR_AUDIT + 11;
  MESID_SVRMNG_GETUPDATEVERINFO = MESID_SVRMNG_START + SVRMNG_MINORFUNC_CLIENTUPDATE shl MESID_MINORFUNC_SHIFT + 12;
  MESID_SVRMNG_GETUPDATEFILE = MESID_SVRMNG_START + SVRMNG_MINORFUNC_CLIENTUPDATE shl MESID_MINORFUNC_SHIFT + 13;
  MESID_SVRMNG_GETSVRSTATIC_INFO = MESID_SVRMNG_START + SVRMNG_MINORFUNC_GENERAL shl MESID_MINORFUNC_SHIFT +
    MESID_OPERATOR_AUDIT + 14;
  MESID_SVRMNG_REMOTEDESKTOPSTATUS = MESID_SVRMNG_START + SVRMNG_MINORFUNC_REMOTEDESKTOP shl MESID_MINORFUNC_SHIFT +
    MESID_OPERATOR_AUDIT + 17;
  MESID_SVRMNG_SYNCPROGRESS = MESID_SVRMNG_START + SVRMNG_MINORFUNC_FILESYSTEM shl MESID_MINORFUNC_SHIFT +
    MESID_OPERATOR_INTERNAL + 18;
  MESID_SVRMNG_GET_SYNCCONFIG = MESID_SVRMNG_START + SVRMNG_MINORFUNC_FILESYSTEM shl MESID_MINORFUNC_SHIFT +
    MESID_OPERATOR_ACCESS + 42;
  MESID_SVRMNG_ADD_SYNCCONFIG = MESID_SVRMNG_START + SVRMNG_MINORFUNC_FILESYSTEM shl MESID_MINORFUNC_SHIFT +
    MESID_OPERATOR_ADD + 43;
  MESID_SVRMNG_ADD_LOCALSYNCCONFIG = MESID_SVRMNG_START + SVRMNG_MINORFUNC_FILESYSTEM shl MESID_MINORFUNC_SHIFT +
    MESID_OPERATOR_INTERNAL + 44;
  MESID_SVRMNG_DEL_SYNCCONFIG = MESID_SVRMNG_START + SVRMNG_MINORFUNC_FILESYSTEM shl MESID_MINORFUNC_SHIFT +
    MESID_OPERATOR_DELETE + 45;
  MESID_SVRMNG_SEARCH_COMPLATE = MESID_SVRMNG_START + SVRMNG_MINORFUNC_FILESYSTEM shl MESID_MINORFUNC_SHIFT +
    MESID_OPERATOR_INTERNAL + 47;
  MESID_SVRMNG_ADD_SYNCPATHFILEENTRY = MESID_SVRMNG_START + SVRMNG_MINORFUNC_FILESYSTEM shl MESID_MINORFUNC_SHIFT +
    MESID_OPERATOR_ADD + 48;
  MESID_SVRMNG_SYNCUPDATEFILE = MESID_SVRMNG_START + SVRMNG_MINORFUNC_FILESYSTEM shl MESID_MINORFUNC_SHIFT +
    MESID_OPERATOR_ADD + 50;
  MESID_SVRMNG_VERIFYAUTHCODE = MESID_SVRMNG_START + SVRMNG_MINORFUNC_SOFTAUTH shl MESID_MINORFUNC_SHIFT + 51;
  MESID_SVRMNG_SENDINPUTINFO = MESID_SVRMNG_START + SVRMNG_MINORFUNC_REMOTEDESKTOP shl MESID_MINORFUNC_SHIFT + 55;
  MESID_SVRMNG_HOSTPARAMCHANGED = MESID_SVRMNG_START + SVRMNG_MINORFUNC_GENERAL shl MESID_MINORFUNC_SHIFT +
    MESID_OPERATOR_INTERNAL + 56;
  MESID_SVRMNG_REGREMOTEDESK = MESID_SVRMNG_START + SVRMNG_MINORFUNC_REMOTEDESKTOP shl MESID_MINORFUNC_SHIFT +
    MESID_OPERATOR_INTERNAL + 57;
  MESID_SVRMNG_UNREGREMOTEDESK = MESID_SVRMNG_START + SVRMNG_MINORFUNC_REMOTEDESKTOP shl MESID_MINORFUNC_SHIFT +
    MESID_OPERATOR_INTERNAL + 58;

  MESID_SVRMNG_SVRSTATICDATA = MESID_SVRMNG_START + SVRMNG_MINORFUNC_GENERAL shl MESID_MINORFUNC_SHIFT +
    MESID_OPERATOR_ACCESS + MESID_OPERATOR_INTERNAL + 90;

  MESID_SVRMNG_RETURN = MESID_SVRMNG_START + MESID_RETURN;
  MESID_SVRMNG_SHUTDOWNING = MESID_SVRMNG_RETURN + 2;
  MESID_SVRMNG_SENDPROCESSINFO = MESID_SVRMNG_RETURN + 3;
  MESID_SVRMNG_UPDATECOMPLETE = MESID_SVRMNG_RETURN + 4;
  MESID_SVRMNG_RESP_REQUESTDESKTOP = MESID_SVRMNG_RETURN + 5;
  MESID_SVRMNG_OBJPOOLINFOLIST = MESID_SVRMNG_RETURN + 6;
  MESID_SVRMNG_PROCOBJINFO = MESID_SVRMNG_RETURN + 7;
  MESID_SVRMNG_UPDATEDEVICE = MESID_SVRMNG_RETURN + 8;
  MESID_SVRMNG_DEVICEOFFLINE = MESID_SVRMNG_RETURN + 9;
  MESID_SVRMNG_SETUPDATEFREQUENCY = MESID_SVRMNG_RETURN + 10;
  MESID_SVRMNG_CMD_GETDISP = MESID_SVRMNG_RETURN + 11;
  MESID_SVRMNG_DEVICEDISP = MESID_SVRMNG_RETURN + 12;
  MESID_SVRMNG_CMD_DEVSHUTDOWN = MESID_SVRMNG_RETURN + 13;
  MESID_SVRMNG_SENDDEVLIST = MESID_SVRMNG_RETURN + 14;
  MESID_SVRMNG_RESP_STOPDESKTOP = MESID_SVRMNG_RETURN + 15;
  MESID_SVRMNG_DELETEDEVCONFIG = MESID_SVRMNG_RETURN + 17;
  MESID_SVRMNG_SENDCLIENTVERINFO = MESID_SVRMNG_RETURN + 23;
  MESID_SVRMNG_SENDFILECONTENT = MESID_SVRMNG_RETURN + 24;
  MESID_SVRMNG_CLIENTPROJECTNOTFOUND = MESID_SVRMNG_RETURN + 25;
  MESID_SVRMNG_CLIENTPROJECTUPDATED = MESID_SVRMNG_RETURN + 27;
  MESID_SVRMNG_SENDSVRSTATICINFO = MESID_SVRMNG_RETURN + 28;
  MESID_SVRMNG_UPDATEUPDATEABLEFILE = MESID_SVRMNG_RETURN + 29;
  MESID_SVRMNG_UPDATEABLEFILEDELED = MESID_SVRMNG_RETURN + 30;
  MESID_SVRMNG_INPUTOUTPUTBUF = MESID_SVRMNG_RETURN + 32;
  MESID_SVRMNG_SENDSYNCFILEINFOS = MESID_SVRMNG_RETURN + 34;
  MESID_SVRMNG_SYNCCONFIGDELED = MESID_SVRMNG_RETURN + 35;
  MESID_SVRMNG_SYNCCONFIGDETAILINPROGRESS = MESID_SVRMNG_RETURN + 37;
  MESID_SVRMNG_UPDATESYNCPATHFILEENTRY = MESID_SVRMNG_RETURN + 38;
  MESID_SVRMNG_VERIFYAUTHCODERESP = MESID_SVRMNG_RETURN + 39;
  MESID_SVRMNG_UPDATEAUTHCODE = MESID_SVRMNG_RETURN + 40;
  MESID_SVRMNG_AUTHCODEDELED = MESID_SVRMNG_RETURN + 41;
  MESID_SVRMNG_HOSTFILESYSTEMINFO = MESID_SVRMNG_RETURN + 42;
  // MESID_SVRMNG_QUERYOBJ = MESID_SVRMNG_GETQUERYOBJ + MESID_RETURN;

  LOGID_SVRMNG_MODULE = LOGID_MODULE_MESSAGE + LOGID_MODULE_SVRMNG;
  LOGID_SVRMNG_SHUTDOWN = LOGID_SVRMNG_MODULE + 1;
  LOGID_SVRMNG_UPDATE_PROGRAM = LOGID_SVRMNG_MODULE + 2;
  LOGID_SVRMNG_RESTART_PROGRAM = LOGID_SVRMNG_MODULE + 3;
  LOGID_SVRMNG_SOMEONEVERIFYAUTHCODE = LOGID_SVRMNG_MODULE + 4;
  LOGID_SVRMNG_STARTDESKFAIL = LOGID_SVRMNG_MODULE + 5;
  LOGID_SVRMNG_STARTDESK = LOGID_SVRMNG_MODULE + 6;
  LOGID_SVRMNG_STOPDESKFAIL = LOGID_SVRMNG_MODULE + 7;
  LOGID_SVRMNG_STOPDESK = LOGID_SVRMNG_MODULE + 8;
  LOGID_SVRMNG_DESKTOPSTATUS_STARTED = LOGID_SVRMNG_MODULE + 9;
  LOGID_SVRMNG_DESKTOPSTATUS_STOPED = LOGID_SVRMNG_MODULE + 10;

  SVRSTATICDATAID_INPUTCONN = 1;
  SVRSTATICDATAID_OUTPUTCONN = 2;
  SVRSTATICDATAID_INPUTDATA = 3;
  SVRSTATICDATAID_OUTPUTDATA = 4;

type
  TDESK_BUFFER = record
    Len: Longword;
    Buf: array [0 .. 0] of Byte;
  end;

  PDESK_BUFFER = ^TDESK_BUFFER;

  TUPDATE_TYPE = (utNone, utFixedPath, utUploadFile, utAutoCompiler);

  TServerInfoObj = class(TSerialObj)
  private
    FComputerName: CommonString;
    FOS: CommonString;
    FOSVersion: CommonString;
    FRAM: uint64;
    FMnimumApplicationAddress: uint64;
    FMaximumApplicationAddress: uint64;
    FActiveProcessorMask: DWORD_PTR;
    FNumberOfProcessors: DWORD;
    FProcessorType: DWORD;
    FAllocationGranularity: DWORD;
    FPageSize: DWORD;
    FSvrTimer: Longword;
    FProcessorLevel: Word;
    FProcessorRevision: Word;
    FProcessorArchitecture: Word;
  protected
    procedure DoAssign(Source: TSerialObj); override;
    procedure DoClone(Target: TSerialObj); override;
    procedure DoReadFromPack(PropertyIdx, Len: Longword; Buf: TIOCPDataCollecter); override;
    procedure DoWritePropertyToPack(dp: TIOCPDataCollecter); override;
  public
    class function ClassID: Longword; override;
    procedure Return; override;

    property ComputerName: CommonString read FComputerName write FComputerName;
    property OS: CommonString read FOS write FOS;
    property OSVersion: CommonString read FOSVersion write FOSVersion;
    property RAM: uint64 read FRAM write FRAM;
    property MnimumApplicationAddress: uint64 read FMnimumApplicationAddress write FMnimumApplicationAddress;
    property MaximumApplicationAddress: uint64 read FMaximumApplicationAddress write FMaximumApplicationAddress;
    property ActiveProcessorMask: DWORD_PTR read FActiveProcessorMask write FActiveProcessorMask;
    property NumberOfProcessors: DWORD read FNumberOfProcessors write FNumberOfProcessors;
    property ProcessorType: DWORD read FProcessorType write FProcessorType;
    property AllocationGranularity: DWORD read FAllocationGranularity write FAllocationGranularity;
    property PageSize: DWORD read FPageSize write FPageSize;
    property ProcessorLevel: Word read FProcessorLevel write FProcessorLevel;
    property ProcessorRevision: Word read FProcessorRevision write FProcessorRevision;
    property ProcessorArchitecture: Word read FProcessorArchitecture write FProcessorArchitecture;
    property SvrTimer: Longword read FSvrTimer write FSvrTimer;
  end;

  TSvrProcessInfoObj = class(TSerialObj)
  private
    FImagePath: CommonString;
    FProcessName: CommonString;
    FProcessID: Longword;
    FThreadCount: Longword;
    FParentProcessID: Longword;
    FWorkSetSize: Longword;
  protected
    procedure DoAssign(Source: TSerialObj); override;
    procedure DoClone(Target: TSerialObj); override;
    procedure DoReadFromPack(PropertyIdx, Len: Longword; Buf: TIOCPDataCollecter); override;
    procedure DoWritePropertyToPack(dp: TIOCPDataCollecter); override;
  public
    class function ClassID: Longword; override;
    procedure Return; override;

    property ParentProcessID: Longword read FParentProcessID write FParentProcessID;
    property ProcessID: Longword read FProcessID write FProcessID;
    property ThreadCount: Longword read FThreadCount write FThreadCount;
    property WorkSetSize: Longword read FWorkSetSize write FWorkSetSize;
    property ProcessName: CommonString read FProcessName write FProcessName;
    property ImagePath: CommonString read FImagePath write FImagePath;
  end;

  TSvrUpdateInfo = class(TSerialObj)
  private
    FPathOrFileName: commonstring;
    FUpdateType: TUPDATE_TYPE;
  protected
    procedure DoAssign(Source: TSerialObj); override;
    procedure DoClone(Target: TSerialObj); override;
    procedure DoReadFromPack(PropertyIdx, Len: Longword; Buf: TIOCPDataCollecter); override;
    procedure DoWritePropertyToPack(dp: TIOCPDataCollecter); override;
  public
    class function ClassID: Longword; override;
    procedure Return; override;

    property UpdateType: TUPDATE_TYPE read FUpdateType write FUpdateType;
    property PathOrFileName: CommonString read FPathOrFileName write FPathOrFileName;
  end;

  TDebugObjPoolInfo = class(TSerialObj)
  private
    FClsName: CommonString;
    FImageFileName: CommonString;
    FAccessCount: Longword;
    FReturnCount: Longword;
    FRequestCount: Longword;
    FMaxThreshold: Longword;
    FClsID: Longword;
    FMinThreshold: Longword;
    FCountInLib: Longword;
    FCreateCount: Longword;
    FFreeCount: Longword;
  protected
    procedure DoAssign(Source: TSerialObj); override;
    procedure DoClone(Target: TSerialObj); override;
    procedure DoReadFromPack(PropertyIdx, Len: Longword; Buf: TIOCPDataCollecter); override;
    procedure DoWritePropertyToPack(dp: TIOCPDataCollecter); override;
  public
    class function ClassID: Longword; override;
    procedure Return; override;

    property ClsName: CommonString read FClsName write FClsName;
    property ClsID: Longword read FClsID write FClsID;
    property CountInLib: Longword read FCountInLib write FCountInLib;
    property MinThreshold: Longword read FMinThreshold write FMinThreshold;
    property MaxThreshold: Longword read FMaxThreshold write FMaxThreshold;
    property AccessCount: Longword read FAccessCount write FAccessCount;
    property RequestCount: Longword read FRequestCount write FRequestCount;
    property ReturnCount: Longword read FReturnCount write FReturnCount;
    property CreateCount: Longword read FCreateCount write FCreateCount;
    property FreeCount: Longword read FFreeCount write FFreeCount;
    property ImageFileName: CommonString read FImageFileName write FImageFileName;
  end;

  TDebugReqObjInfo = class(TSerialObj)
  private
    FReqClsName: CommonString;
    FReturnCount: Longword;
    FRequestCount: Longword;
  protected
    procedure DoAssign(Source: TSerialObj); override;
    procedure DoClone(Target: TSerialObj); override;
    procedure DoReadFromPack(PropertyIdx, Len: Longword; Buf: TIOCPDataCollecter); override;
    procedure DoWritePropertyToPack(dp: TIOCPDataCollecter); override;
  public
    class function ClassID: Longword; override;
    procedure Return; override;

    property ReqClsName: CommonString read FReqClsName write FReqClsName;
    property RequestCount: Longword read FRequestCount write FRequestCount;
    property ReturnCount: Longword read FReturnCount write FReturnCount;
  end;

  TDebugProcObjInfo = class(TSerialObj)
  private
    FObjClassName: CommonString;
    FProcessedMsgCount: Longword;
    FUnHandledExceptCount: Longword;
  protected
    procedure DoAssign(Source: TSerialObj); override;
    procedure DoClone(Target: TSerialObj); override;
    procedure DoReadFromPack(PropertyIdx, Len: Longword; Buf: TIOCPDataCollecter); override;
    procedure DoWritePropertyToPack(dp: TIOCPDataCollecter); override;
  public
    class function ClassID: Longword; override;
    procedure Return; override;

    property ObjClassName: CommonString read FObjClassName write FObjClassName;
    property ProcessedMsgCount: Longword read FProcessedMsgCount write FProcessedMsgCount;
    property UnHandledExceptCount: Longword read FUnHandledExceptCount write FUnHandledExceptCount;
  end;

  TSVR_STATIC_DATA = packed record
    case integer of
      0:
        (RollValue: Longword);
      1:
        (StaticID, Value: Word);
  end;

  TRemoteDeskObj = class(TSerialObj)
  private
    FRemoteName: CommonString;
    procedure SetRemoteName(const Value: CommonString);
  protected
    procedure DoAssign(Source: TSerialObj); override;
    procedure DoClone(Target: TSerialObj); override;
    procedure DoReadFromPack(PropertyIdx, Len: Longword; Buf: TIOCPDataCollecter); override;
    procedure DoWritePropertyToPack(dp: TIOCPDataCollecter); override;
  public
    class function ClassID: Longword; override;
    procedure Return; override;

    property RemoteName: CommonString read FRemoteName write SetRemoteName;
  end;

  THostFriendInfo = class(TSerialObj)
  private
    FFriendName: CommonString;
    function GetHostName: CommonString;
    procedure SetFriendName(const Value: CommonString);
    procedure SetHostName(const Value: CommonString);
  protected
    procedure DoAssign(Source: TSerialObj); override;
    procedure DoClone(Target: TSerialObj); override;
    procedure DoReadFromPack(PropertyIdx, Len: Longword; Buf: TIOCPDataCollecter); override;
    procedure DoWritePropertyToPack(dp: TIOCPDataCollecter); override;
  public
    class function ClassID: Longword; override;
    procedure Return; override;

    property HostName: CommonString read GetHostName write SetHostName;
    property FriendName: CommonString read FFriendName write SetFriendName;
  end;

  TInputInfo = class(TSerialObj)
  private
    FInputParam: array [0 .. 5] of DWORD;
  protected
    procedure DoAssign(Source: TSerialObj); override;
    procedure DoClone(Target: TSerialObj); override;
    procedure DoReadFromPack(PropertyIdx, Len: Longword; Buf: TIOCPDataCollecter); override;
    procedure DoWritePropertyToPack(dp: TIOCPDataCollecter); override;
  public
    class function ClassID: Longword; override;
    procedure Return; override;

    function BufSize: Longword;
    procedure FromBuf(const Buf; Len: Longword);
    procedure ToBuf(var Buf; Len: Longword);
  end;

const
  FILEOBJ_TYPE_HARDDRIVER = 0;
  FILEOBJ_TYPE_DIRECTORY = 1;
  FILEOBJ_TYPE_FILE = 2;

  ID_SYSDURATION: TID_OBJ = (IDDetail: (ObjType: OBJTYPE_ID; SubType: IDSUBTYPE_RECORD;
    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $51))));
  S_SYSDURATION = '系统持续时间';
//  ID_LASTUPDATE_OLD: TID_OBJ = (IDDetail: (ObjType: 5; SubType: $EB;
//    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $52))));
  ID_LASTUPDATE: TID_OBJ = (IDDetail: (ObjType: OBJTYPE_ID; SubType: IDSUBTYPE_RECORD;
    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $52))));
  S_LASTUPDATE = '上次更新时间';
  S_LASTUPDATE_COMMENT = '上次更新时间';
//  ID_PAUSEUPDATE_OLD: TID_OBJ = (IDDetail: (ObjType: 5; SubType: $EB;
//    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $53))));
  ID_PAUSEUPDATE: TID_OBJ = (IDDetail: (ObjType: OBJTYPE_ID; SubType: IDSUBTYPE_FUNCTION;
    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $53))));
  S_PAUSEUPDATE = '暂停更新开关';
  S_PAUSEUPDATE_COMMENT = '是否允许根服务器暂停响应更新请求';
//  ID_AUTOUPDATE_OLD: TID_OBJ = (IDDetail: (ObjType: 5; SubType: $EB;
//    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $54))));
  ID_AUTOUPDATE: TID_OBJ = (IDDetail: (ObjType: OBJTYPE_ID; SubType: IDSUBTYPE_FUNCTION;
    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $54))));
  S_AUTOUPDATEFLAG = '自动更新开关';
  S_AUTOUPDATE_COMMENT = '是否允许本地文件与根服务器保持一致';
//  ID_DESKFLAG_OLD: TID_OBJ = (IDDetail: (ObjType: 5; SubType: $EB;
//    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $55))));
  ID_DESKFLAG: TID_OBJ = (IDDetail: (ObjType: OBJTYPE_ID; SubType: IDSUBTYPE_FUNCTION;
    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $55))));
  S_DESKFLAG = '远程桌面开关';
  S_DESKFLAG_COMMENT = '是否允许本地桌面被远端使用';
//  ID_REMOTEDESK_OLD: TID_OBJ = (IDDetail: (ObjType: 5; SubType: $EB;
//    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $57))));
  ID_REMOTEDESK: TID_OBJ = (IDDetail: (ObjType: OBJTYPE_ID; SubType: IDSUBTYPE_TABLE;
    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $57))));
  S_REMOTEDESK = '远程桌面表';
  ID_COMMONUSEHOSTTABLE: TID_OBJ = (IDDetail: (ObjType: OBJTYPE_ID; SubType: IDSUBTYPE_TABLE;
    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $58))));
  S_COMMONUSEHOSTTABLE = '常用主机表';
//  ID_HOSTPARAMTABLE_OLD: TID_OBJ = (IDDetail: (ObjType: 5; SubType: $EB;
//    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $59))));
  ID_HOSTPARAMTABLE: TID_OBJ = (IDDetail: (ObjType: OBJTYPE_ID; SubType: IDSUBTYPE_TABLE;
    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $59))));
  S_HOSTPARAMTABLE = '主机参数表';
//  ID_AUTHRECORDTABLE_OLD: TID_OBJ = (IDDetail: (ObjType: 5; SubType: $EB;
//    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $5A))));
  ID_AUTHRECORDTABLE: TID_OBJ = (IDDetail: (ObjType: OBJTYPE_ID; SubType: IDSUBTYPE_TABLE;
    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $5A))));
  S_AUTHRECORDTABLE = '软件注册号表';
//  ID_INCOMINGFILETABLE_OLD: TID_OBJ = (IDDetail: (ObjType: 5; SubType: $EB;
//    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $5B))));
  ID_INCOMINGFILETABLE: TID_OBJ = (IDDetail: (ObjType: OBJTYPE_ID; SubType: IDSUBTYPE_TABLE;
    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $5B))));
  S_INCOMINGFILETABLE = '可写文件表';
  S_LOCALROOTHOSTPARAMPRIORITY = '允许本机 root 成员访问本机参数表';
  ID_DESKFUNC: TID_OBJ = (IDDetail: (ObjType: OBJTYPE_ID; SubType: IDSUBTYPE_FUNCTION;
    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $5C))));
  S_DESKFUNC = '远程桌面功能';
  S_DESKFUNC_COMMENT = '本地桌面启动关闭功能开关';
  ID_RESTARTSVR: TID_OBJ = (IDDetail: (ObjType: OBJTYPE_ID; SubType: IDSUBTYPE_FUNCTION;
    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $5D))));
  S_RESTARTSVR = '重启服务程序';
  ID_REBOOT: TID_OBJ = (IDDetail: (ObjType: OBJTYPE_ID; SubType: IDSUBTYPE_FUNCTION;
    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $5E))));
  S_REBOOT = '重启主机';
  ID_SHUTDOWN: TID_OBJ = (IDDetail: (ObjType: OBJTYPE_ID; SubType: IDSUBTYPE_FUNCTION;
    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $5F))));
  S_SHUTDOWN = '关闭主机';
  ID_DEVICEINFO: TID_OBJ = (IDDetail: (ObjType: OBJTYPE_ID; SubType: IDSUBTYPE_RECORD;
    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $60))));
  S_DEVICEINFO = '主机信息';
  ID_HPDEVICENAME: TID_OBJ = (IDDetail: (ObjType: OBJTYPE_ID; SubType: IDSUBTYPE_RECORD;
    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $61))));
  S_HPDEVICENAME = '主机名';
  ID_HPDEVICETYPE: TID_OBJ = (IDDetail: (ObjType: OBJTYPE_ID; SubType: IDSUBTYPE_RECORD;
    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $62))));
  S_HPDEVICETYPE = '主机操作系统';
  ID_HPDEVICEPRDID: TID_OBJ = (IDDetail: (ObjType: OBJTYPE_ID; SubType: IDSUBTYPE_RECORD;
    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $63))));
  S_HPDEVICEPRDID = '主机产品ID';
  ID_DBGOUTPUT: TID_OBJ = (IDDetail: (ObjType: OBJTYPE_ID; SubType: IDSUBTYPE_RECORD;
    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $64))));
  S_DBGOUTPUT = '调试输出';
  ID_MAINPROCVER: TID_OBJ = (IDDetail: (ObjType: OBJTYPE_ID; SubType: IDSUBTYPE_RECORD;
    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $65))));
  S_MAINPROCVER = '主进程版本';
  ID_ROOTSWAPPATH: TID_OBJ = (IDDetail: (ObjType: OBJTYPE_ID; SubType: IDSUBTYPE_RECORD;
    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $66))));
  S_ROOTSWAPPATH = '根主机交换目录';
  ID_HOSTFILESYSTEM: TID_OBJ = (IDDetail: (ObjType: OBJTYPE_ID; SubType: IDSUBTYPE_RECORD;
    SubID: (IDBuf: ($D7, $D0, $10, $E0, $4E, $43, $8E, $BE, $37, $3A, $24, $7F, $91, $67))));
  S_HOSTFILESYSTEM = '主机文件系统';
  S_CURUSERSYNCTABLE = '当前根账户同步表';

function GenSyncTableIDByUID(const uid: TID_OBJ): TID_OBJ; // 通过用户ID生成同步表ID
procedure SendSvrStaticData(Sender: TObjBase; StaticDataID, Value: Word);

implementation

uses unitObjPool, unitMisc, unitCommonIntf;

function GenSyncTableIDByUID(const uid: TID_OBJ): TID_OBJ;
begin
  Result := uid;
  Result.IDDetail.SubType := IDSUBTYPE_TABLE;
  Result.IDDetail.SubID.HostID.HostID[11] := 01;
end;

{ TServerInfoObj }

class function TServerInfoObj.ClassID: Longword;
begin
  Result := CLASSID_SERVERINFOOBJ;
end;

procedure TServerInfoObj.DoAssign(Source: TSerialObj);
var
  src: TServerInfoObj absolute Source;
begin
  inherited;
  FRAM := src.FRAM;
  FComputerName := src.FComputerName;
  FOS := src.FOS;
  FOSVersion := src.FOSVersion;
  FSvrTimer := src.FSvrTimer;
  FMnimumApplicationAddress := src.FMnimumApplicationAddress;
  FMaximumApplicationAddress := src.FMaximumApplicationAddress;
  FActiveProcessorMask := src.FActiveProcessorMask;
  FNumberOfProcessors := src.FNumberOfProcessors;
  FProcessorType := src.FProcessorType;
  FAllocationGranularity := src.FAllocationGranularity;
  FPageSize := src.FPageSize;
  FProcessorLevel := src.FProcessorLevel;
  FProcessorRevision := src.FProcessorRevision;
  FProcessorArchitecture := src.FProcessorArchitecture;
end;

procedure TServerInfoObj.DoClone(Target: TSerialObj);
var
  tgt: TServerInfoObj absolute Target;
begin
  inherited;
  tgt.FRAM := FRAM;
  tgt.FComputerName := FComputerName;
  tgt.FOS := FOS;
  tgt.FOSVersion := FOSVersion;
  tgt.FSvrTimer := FSvrTimer;
  tgt.FMnimumApplicationAddress := FMnimumApplicationAddress;
  tgt.FMaximumApplicationAddress := FMaximumApplicationAddress;
  tgt.FActiveProcessorMask := FActiveProcessorMask;
  tgt.FNumberOfProcessors := FNumberOfProcessors;
  tgt.FProcessorType := FProcessorType;
  tgt.FAllocationGranularity := FAllocationGranularity;
  tgt.FPageSize := FPageSize;
  tgt.FProcessorLevel := FProcessorLevel;
  tgt.FProcessorRevision := FProcessorRevision;
  tgt.FProcessorArchitecture := FProcessorArchitecture;
end;

procedure TServerInfoObj.DoReadFromPack(PropertyIdx, Len: Longword; Buf: TIOCPDataCollecter);
begin
  case PropertyIdx of
    1:
      ReadCommonStringFromPack(Buf, FComputerName, Len);
    2:
      ReadCommonStringFromPack(Buf, FOS, Len);
    3:
      ReadCommonStringFromPack(Buf, FOSVersion, Len);
    4:
      Buf.ReadBuf(FRAM, Len);
    5:
      Buf.ReadBuf(FNumberOfProcessors, Len);
  else
    inherited;
  end;
end;

procedure TServerInfoObj.DoWritePropertyToPack(dp: TIOCPDataCollecter);
begin
  inherited;
  WriteCommonStringToPack(dp, 1, FComputerName);
  WriteCommonStringToPack(dp, 2, FOS);
  WriteCommonStringToPack(dp, 3, FOSVersion);
  WritePropertyToPack(dp, 4, SizeOf(FRAM) + SizeOf(FMnimumApplicationAddress) + SizeOf(FMaximumApplicationAddress) +
    SizeOf(FActiveProcessorMask), FRAM);
  WritePropertyToPack(dp, 5, SizeOf(FNumberOfProcessors) + SizeOf(FProcessorType) + SizeOf(FAllocationGranularity) +
    SizeOf(FPageSize) + SizeOf(FSvrTimer) + SizeOf(FProcessorLevel) + SizeOf(FProcessorRevision) +
    SizeOf(FProcessorArchitecture), FNumberOfProcessors);
end;

procedure TServerInfoObj.Return;
begin
  inherited;
  FComputerName := '';
  FOS := '';
  FOSVersion := '';
  FRAM := 0;
  FMnimumApplicationAddress := 0;
  FMaximumApplicationAddress := 0;
  FActiveProcessorMask := 0;
  FNumberOfProcessors := 0;
  FProcessorType := 0;
  FAllocationGranularity := 0;
  FPageSize := 0;
  FSvrTimer := 0;
  FProcessorLevel := 0;
  FProcessorRevision := 0;
  FProcessorArchitecture := 0;
end;

{ TSvrProcessInfoObj }

class function TSvrProcessInfoObj.ClassID: Longword;
begin
  Result := CLASSID_SVRPROCESSINFOOBJ;
end;

procedure TSvrProcessInfoObj.DoAssign(Source: TSerialObj);
var
  src: TSvrProcessInfoObj absolute Source;
begin
  inherited;
  FProcessID := src.FProcessID;
  FImagePath := src.FImagePath;
  FProcessName := src.FProcessName;
  FThreadCount := src.FThreadCount;
  FParentProcessID := src.FParentProcessID;
  FWorkSetSize := src.FWorkSetSize;
end;

procedure TSvrProcessInfoObj.DoClone(Target: TSerialObj);
var
  tgt: TSvrProcessInfoObj absolute Target;
begin
  inherited;
  tgt.FParentProcessID := FParentProcessID;
  tgt.FProcessID := FProcessID;
  tgt.FThreadCount := FThreadCount;
  tgt.FImagePath := FImagePath;
  tgt.FProcessName := FProcessName;
  tgt.FWorkSetSize := FWorkSetSize;
end;

procedure TSvrProcessInfoObj.DoReadFromPack(PropertyIdx, Len: Longword; Buf: TIOCPDataCollecter);
begin
  case PropertyIdx of
    1:
      Buf.ReadBuf(FProcessID, Len);
    2:
      ReadCommonStringFromPack(Buf, FImagePath, Len);
    3:
      ReadCommonStringFromPack(Buf, FProcessName, Len);
  else
    inherited;
  end;
end;

procedure TSvrProcessInfoObj.DoWritePropertyToPack(dp: TIOCPDataCollecter);
begin
  inherited;
  WritePropertyToPack(dp, 1, SizeOf(FProcessID) * 4, FProcessID);
  WriteCommonStringToPack(dp, 2, FImagePath);
  WriteCommonStringToPack(dp, 3, FProcessName);
end;

procedure TSvrProcessInfoObj.Return;
begin
  inherited;
  FProcessID := 0;
  FThreadCount := 0;
  FParentProcessID := 0;
  FWorkSetSize := 0;
  FImagePath := '';
  FProcessName := '';
end;

{ TSvrUpdateInfo }

class function TSvrUpdateInfo.ClassID: Longword;
begin
  Result := CLASSID_UPDATESERVER_INFOOBJ;
end;

procedure TSvrUpdateInfo.DoAssign(Source: TSerialObj);
var
  src: TSvrUpdateInfo absolute Source;
begin
  inherited;
  FUpdateType := src.FUpdateType;
  FPathOrFileName := src.FPathOrFileName;
end;

procedure TSvrUpdateInfo.DoClone(Target: TSerialObj);
var
  tgt: TSvrUpdateInfo absolute Target;
begin
  inherited;
  tgt.FUpdateType := FUpdateType;
  tgt.FPathOrFileName := FPathOrFileName;
end;

procedure TSvrUpdateInfo.DoReadFromPack(PropertyIdx, Len: Longword; Buf: TIOCPDataCollecter);
begin
  case PropertyIdx of
    1:
      Buf.ReadBuf(FUpdateType, Len);
    2:
      ReadCommonStringFromPack(Buf, FPathOrFileName, Len);
  else
    inherited;
  end;
end;

procedure TSvrUpdateInfo.DoWritePropertyToPack(dp: TIOCPDataCollecter);
begin
  inherited;
  WritePropertyToPack(dp, 1, SizeOf(FUpdateType), FUpdateType);
  WriteCommonStringToPack(dp, 2, FPathOrFileName);
end;

procedure TSvrUpdateInfo.Return;
begin
  inherited;
  FUpdateType := utNone;
  FPathOrFileName := '';
end;

{ TDebugObjPoolInfo }

class function TDebugObjPoolInfo.ClassID: Longword;
begin
  Result := CLASSID_DEBUG_OBJPOOLINFO;
end;

procedure TDebugObjPoolInfo.DoAssign(Source: TSerialObj);
var
  src: TDebugObjPoolInfo absolute Source;
begin
  inherited;
  FAccessCount := src.FAccessCount;
  FReturnCount := src.FReturnCount;
  FClsName := src.FClsName;
  FRequestCount := src.FRequestCount;
  FMaxThreshold := src.FMaxThreshold;
  FClsID := src.FClsID;
  FMinThreshold := src.FMinThreshold;
  FCountInLib := src.FCountInLib;
  FCreateCount := src.FCreateCount;
  FFreeCount := src.FFreeCount;
  FImageFileName := src.FImageFileName;
end;

procedure TDebugObjPoolInfo.DoClone(Target: TSerialObj);
var
  tgt: TDebugObjPoolInfo ABSOLUTE Target;
begin
  inherited;
  tgt.FAccessCount := FAccessCount;
  tgt.FReturnCount := FReturnCount;
  tgt.FClsName := FClsName;
  tgt.FRequestCount := FRequestCount;
  tgt.FMaxThreshold := FMaxThreshold;
  tgt.FClsID := FClsID;
  tgt.FMinThreshold := FMinThreshold;
  tgt.FCountInLib := FCountInLib;
  tgt.FCreateCount := FCreateCount;
  tgt.FFreeCount := FFreeCount;
  tgt.FImageFileName := FImageFileName;
end;

procedure TDebugObjPoolInfo.DoReadFromPack(PropertyIdx, Len: Longword; Buf: TIOCPDataCollecter);
begin
  case PropertyIdx of
    1:
      Buf.ReadBuf(FAccessCount, Len);
    2:
      ReadCommonStringFromPack(Buf, FClsName, Len);
    3:
      ReadCommonStringFromPack(Buf, FImageFileName, Len);
  else
    inherited;
  end;
end;

procedure TDebugObjPoolInfo.DoWritePropertyToPack(dp: TIOCPDataCollecter);
begin
  inherited;
  WritePropertyToPack(dp, 1, SizeOf(FAccessCount) + SizeOf(FReturnCount) + SizeOf(FRequestCount) + SizeOf(FMaxThreshold)
    + SizeOf(FClsID) + SizeOf(FMinThreshold) + SizeOf(FCountInLib) + SizeOf(FCreateCount) + SizeOf(FFreeCount),
    FAccessCount);
  WriteCommonStringToPack(dp, 2, FClsName);
  WriteCommonStringToPack(dp, 3, FImageFileName);
end;

procedure TDebugObjPoolInfo.Return;
begin
  inherited;
  FAccessCount := 0;
  FReturnCount := 0;
  FClsName := '';
  FRequestCount := 0;
  FMaxThreshold := 0;
  FClsID := 0;
  FMinThreshold := 0;
  FCountInLib := 0;
  FCreateCount := 0;
  FImageFileName := '';
end;

{ TDebugReqInfo }

class function TDebugReqObjInfo.ClassID: Longword;
begin
  Result := CLASSID_DEBUG_REQOBJINFO;
end;

procedure TDebugReqObjInfo.DoAssign(Source: TSerialObj);
var
  src: TDebugReqObjInfo ABSOLUTE Source;
begin
  inherited;
  FReturnCount := src.FReturnCount;
  FReqClsName := src.FReqClsName;
  FRequestCount := src.FRequestCount;
end;

procedure TDebugReqObjInfo.DoClone(Target: TSerialObj);
var
  tgt: TDebugReqObjInfo ABSOLUTE Target;
begin
  inherited;
  tgt.FReturnCount := FReturnCount;
  tgt.FReqClsName := FReqClsName;
  tgt.FRequestCount := FRequestCount;
end;

procedure TDebugReqObjInfo.DoReadFromPack(PropertyIdx, Len: Longword; Buf: TIOCPDataCollecter);
begin
  case PropertyIdx of
    1:
      Buf.ReadBuf(FReturnCount, Len);
    2:
      ReadCommonStringFromPack(Buf, FReqClsName, Len);
  else
    inherited;
  end;
end;

procedure TDebugReqObjInfo.DoWritePropertyToPack(dp: TIOCPDataCollecter);
begin
  inherited;
  WritePropertyToPack(dp, 1, SizeOf(FRequestCount) + SizeOf(FReturnCount), FReturnCount);
  WriteCommonStringToPack(dp, 2, FReqClsName);
end;

procedure TDebugReqObjInfo.Return;
begin
  inherited;
  FReqClsName := '';
  FReturnCount := 0;
  FRequestCount := 0;
end;

{ TDebugProcObjInfo }

class function TDebugProcObjInfo.ClassID: Longword;
begin
  Result := CLASSID_DEBUG_PROCOBJINFO;
end;

procedure TDebugProcObjInfo.DoAssign(Source: TSerialObj);
var
  src: TDebugProcObjInfo ABSOLUTE Source;
begin
  inherited;
  FObjClassName := src.FObjClassName;
  FProcessedMsgCount := src.FProcessedMsgCount;
  FUnHandledExceptCount := src.FUnHandledExceptCount;
end;

procedure TDebugProcObjInfo.DoClone(Target: TSerialObj);
var
  tgt: TDebugProcObjInfo ABSOLUTE Target;
begin
  inherited;
  tgt.FObjClassName := FObjClassName;
  tgt.FProcessedMsgCount := FProcessedMsgCount;
  tgt.FUnHandledExceptCount := FUnHandledExceptCount;
end;

procedure TDebugProcObjInfo.DoReadFromPack(PropertyIdx, Len: Longword; Buf: TIOCPDataCollecter);
begin
  case PropertyIdx of
    1:
      Buf.ReadBuf(FProcessedMsgCount, Len);
    2:
      ReadCommonStringFromPack(Buf, FObjClassName, Len);
  else
    inherited;
  end;
end;

procedure TDebugProcObjInfo.DoWritePropertyToPack(dp: TIOCPDataCollecter);
begin
  inherited;
  WriteCommonStringToPack(dp, 2, FObjClassName);
  WritePropertyToPack(dp, 1, SizeOf(FProcessedMsgCount) + SizeOf(FUnHandledExceptCount), FProcessedMsgCount);
end;

procedure TDebugProcObjInfo.Return;
begin
  inherited;
  FObjClassName := '';
  FProcessedMsgCount := 0;
  FUnHandledExceptCount := 0;
end;

{ TDeviceDisplay }

procedure SendSvrStaticData(Sender: TObjBase; StaticDataID, Value: Word);
var
  m: TMsg;
  ssd: TSVR_STATIC_DATA;
begin
  if Sender <> nil then
  begin
    m := Sender.GetAMsg;
    if m <> nil then
    begin
      m.MsgID := MESID_SVRMNG_SVRSTATICDATA;
      m.SourceObjID := Sender.FullObjID;
      m.TargetObjID := OBJID_SVRMNGMODULE;
      ssd.StaticID := StaticDataID;
      ssd.Value := Value;
      m.Data := ssd.RollValue;

      CommonIntf.SendMsgProc(nil, m);
    end;
  end;
end;

{ TRemoteDeskObj }

class function TRemoteDeskObj.ClassID: Longword;
begin
  Result := CLASSID_REMOTEDESKOBJ;
end;

procedure TRemoteDeskObj.DoAssign(Source: TSerialObj);
var
  src: TRemoteDeskObj absolute Source;
begin
  inherited;
  FRemoteName := src.FRemoteName;
end;

procedure TRemoteDeskObj.DoClone(Target: TSerialObj);
var
  tgt: TRemoteDeskObj absolute Target;
begin
  inherited;
  tgt.FRemoteName := FRemoteName;
end;

procedure TRemoteDeskObj.DoReadFromPack(PropertyIdx, Len: Longword; Buf: TIOCPDataCollecter);
begin
  case PropertyIdx of
    1:
      ReadCommonStringFromPack(Buf, FRemoteName, Len);
  else
    inherited;
  end;
end;

procedure TRemoteDeskObj.DoWritePropertyToPack(dp: TIOCPDataCollecter);
begin
  inherited;
  WriteCommonStringToPack(dp, 1, FRemoteName);
end;

procedure TRemoteDeskObj.Return;
begin
  FRemoteName := '';
  inherited;
end;

procedure TRemoteDeskObj.SetRemoteName(const Value: CommonString);
begin
  if FRemoteName <> Value then
  begin
    FRemoteName := Value;
    DoModifyed;
  end;
end;

// { TSvrMngQueryObj }
//
// class function TSvrMngQueryObj.ClassID: Longword;
// begin
// Result := CLASSID_SVRMNGQUERYOBJ;
// end;
//
// procedure TSvrMngQueryObj.Return;
// begin
// inherited;
// FQueryHostParamByID := nil;
// end;

{ THostFriendInfo }

class function THostFriendInfo.ClassID: Longword;
begin
  Result := CLASSID_HOSTFRIENDINFO;
end;

procedure THostFriendInfo.DoAssign(Source: TSerialObj);
var
  src: THostFriendInfo absolute Source;
begin
  inherited;
  if (src.FFriendName <> '') then
    FFriendName := src.FFriendName
  else if FriendName = '' then
    FFriendName := Caption;
end;

procedure THostFriendInfo.DoClone(Target: TSerialObj);
var
  tgt: THostFriendInfo absolute Target;
begin
  inherited;
  tgt.FFriendName := FFriendName;
end;

procedure THostFriendInfo.DoReadFromPack(PropertyIdx, Len: Longword; Buf: TIOCPDataCollecter);
begin
  case PropertyIdx of
    1:
      ReadCommonStringFromPack(Buf, FFriendName, Len);
  else
    inherited;
  end;
end;

procedure THostFriendInfo.DoWritePropertyToPack(dp: TIOCPDataCollecter);
begin
  inherited;
  WriteCommonStringToPack(dp, 1, FFriendName);
end;

function THostFriendInfo.GetHostName: CommonString;
begin
  Result := Caption;
end;

procedure THostFriendInfo.Return;
begin
  inherited;
  FFriendName := '';
end;

procedure THostFriendInfo.SetFriendName(const Value: CommonString);
begin
  if FFriendName <> Value then
  begin
    FFriendName := Value;
    DoModifyed;
  end;
end;

procedure THostFriendInfo.SetHostName(const Value: CommonString);
begin
  Caption := Value;
end;

{ TInputInfo }

function TInputInfo.BufSize: Longword;
begin
  Result := SizeOf(FInputParam);
end;

class function TInputInfo.ClassID: Longword;
begin
  Result := CLASSID_SYSINPUTINFO;
end;

procedure TInputInfo.DoAssign(Source: TSerialObj);
var
  src: TInputInfo absolute Source;
begin
  inherited;
  Move(src.FInputParam, FInputParam, SizeOf(FInputParam));
end;

procedure TInputInfo.DoClone(Target: TSerialObj);
var
  tgt: TInputInfo absolute Target;
begin
  inherited;
  Move(FInputParam, tgt.FInputParam, SizeOf(FInputParam));
end;

procedure TInputInfo.DoReadFromPack(PropertyIdx, Len: Longword; Buf: TIOCPDataCollecter);
begin
  case PropertyIdx of
    1:
      begin
        if Len > SizeOf(FInputParam) then
        begin
          Buf.ReadBuf(FInputParam, SizeOf(FInputParam));
          Dec(Len, SizeOf(FInputParam));
          Buf.DataProcessed(Len);
        end
        else
          Buf.ReadBuf(FInputParam, Len);
      end
  else
    inherited;
  end;
end;

procedure TInputInfo.DoWritePropertyToPack(dp: TIOCPDataCollecter);
begin
  WritePropertyToPack(dp, 1, SizeOf(FInputParam), FInputParam);
  inherited;
end;

procedure TInputInfo.FromBuf(const Buf; Len: Longword);
begin
  if Len > SizeOf(FInputParam) then
    Len := SizeOf(FInputParam);
  Move(Buf, FInputParam, Len);
end;

procedure TInputInfo.Return;
begin
  inherited;
  FillChar(FInputParam, SizeOf(FInputParam), 0);
end;

procedure TInputInfo.ToBuf(var Buf; Len: Longword);
begin
  if Len > SizeOf(FInputParam) then
    Len := SizeOf(FInputParam);
  Move(FInputParam, Buf, Len);
end;

initialization

ObjPool.RegisterObjClass(TServerInfoObj);
ObjPool.RegisterObjClass(TSvrProcessInfoObj);
ObjPool.RegisterObjClass(TSvrUpdateInfo);
ObjPool.RegisterObjClass(TDebugObjPoolInfo);
ObjPool.RegisterObjClass(TDebugReqObjInfo);
ObjPool.RegisterObjClass(TDebugProcObjInfo);
ObjPool.RegisterObjClass(TRemoteDeskObj);
// ObjPool.RegisterObjClass(TSvrMngQueryObj);
ObjPool.RegisterObjClass(THostFriendInfo);
ObjPool.RegisterObjClass(TInputInfo);

end.
